<!DOCTYPE html>
<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport"
    content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
  <meta name="author" content="火星科技 http://mars3d.cn ">
  <meta name="apple-touch-fullscreen" content="yes">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="format-detection" content="telephone=no">
  <meta name="x5-fullscreen" content="true">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
  <!-- 标题及搜索关键字 -->
  <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
  <meta name="description"
    content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型  gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包  地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS" />

  <link rel="shortcut icon" type="image/x-icon" href="http://mars3d.cn/favicon.ico">
  <title>三维地图 | Mars3D | 三维地图 | 火星科技 | 合肥火星科技有限公司</title>


  <!--第三方lib-->
  <script type="text/javascript" src="../lib/include-lib.js" libpath="../lib/"
    include="jquery,font-awesome,bootstrap,layer,haoutil,turf,mars3d"></script>

  <link href="css/style.css" rel="stylesheet" />
  <style>
    .btn-primary {
      margin: 2px;
      width: 60px;
    }
  </style>
</head>

<body class="dark">
  <!--加载前进行操作提示，优化用户体验-->
  <div id="mask" class="signmask" onclick="removeMask()"></div>

  <div id="mars3dContainer" class="mars3d-container"></div>


  <!-- 面板 -->
  <div class="infoview" style="top:30%;width: 100px;text-align: center;">
    <button type="button" id="btnShowAll" class="btn btn-primary active">整体</button>
    <button type="button" id="btnShowF5" class="btn btn-primary">5F</button>
    <button type="button" id="btnShowF4" class="btn btn-primary">4F</button>
    <button type="button" id="btnShowF3" class="btn btn-primary">3F</button>
    <button type="button" id="btnShowF2" class="btn btn-primary">2F</button>
    <button type="button" id="btnShowF1" class="btn btn-primary">1F</button>
    <button type="button" id="btnShowD1" class="btn btn-primary">-1F</button>
  </div>
  <div class="infoview">
    <div>
      室内演示视角：
      <input type="button" class="btn btn-primary" value="教室" onclick="centerAtDX1()" />
      <input type="button" class="btn btn-primary" value="走廊" onclick="centerAtDX2()" />
      <input type="button" class="btn btn-primary" value="楼梯间" onclick="centerAtDX3()" />
    </div>
  </div>



  <script src="./js/common.js"></script>
  <script type="text/javascript">
    'use script' //开发环境建议开启严格模式

    var map

    function initMap(options) {
      //合并属性参数，可覆盖config.json中的对应配置
      var mapOptions = mars3d.Util.merge(options, {
        scene: {
          center: {
            y: 31.842655,
            x: 117.251587,
            z: 304.57,
            heading: 358,
            pitch: -59,
            roll: 0,
          },
          globe: {
            depthTestAgainstTerrain: true,
          },
        },
        layers: [
          {
            id: 1987,
            name: '教学楼',
            type: '3dtiles',
            url: 'http://data.marsgis.cn/3dtiles/bim-daxue/tileset.json',
            position: {
              lng: 117.251229,
              lat: 31.844015,
              alt: 36.2,
            },
            center: {
              y: 31.842655,
              x: 117.251587,
              z: 304.57,
              heading: 358,
              pitch: -59,
              roll: 0,
            },
            maximumScreenSpaceError: 16,
            maximumMemoryUsage: 1024,
            showClickFeature: true,
            pickFeatureStyle: {
              color: '#00FF00',
            },
            popup: 'all',
            show: true,
          },
        ],
      })

      //创建三维地球场景
      map = new mars3d.Map('mars3dContainer', mapOptions)

      // BIM模型处理
      const layerWorkBIM = map.getLayer(1987, 'id')

      //单击事件
      layerWorkBIM.on(mars3d.EventType.click, function (event) {
        console.log('单击了3dtiles图层', event)
      })

      //模型裁剪
      var tilesetPlanClip = new mars3d.thing.TilesetPlanClip({
        layer: layerWorkBIM,
        type: mars3d.thing.TilesetPlanClip.Type.ZR,
        distance: 100,
        clipOutSide: false,
        edgeColor: Cesium.Color.GREY,
        edgeWidth: 2.0,
      })
      map.addThing(tilesetPlanClip)

      //挖地区域
      var terrainPlanClip = new mars3d.thing.TerrainPlanClip({
        positions: [
          [117.251176, 31.843707, 32.24],
          [117.251877, 31.843707, 32.24],
          [117.251877, 31.844216, 32.24],
          [117.251176, 31.844216, 32.24],
        ],
        diffHeight: 10, //高度
        image: './img/textures/excavate_side_min.jpg', //边界墙材质
        imageBottom: './img/textures/excavate_bottom_min.jpg', //底部区域材质
        splitNum: 50, //wall边界插值数
      })
      map.addThing(terrainPlanClip)

      $('#btnShowAll').click(function () {
        terrainPlanClip.show = false
        tilesetPlanClip.distance = 100
      })

      $('#btnShowD1').click(function () {
        terrainPlanClip.show = true
        tilesetPlanClip.distance = -3.6
      })
      $('#btnShowF1').click(function () {
        terrainPlanClip.show = false
        tilesetPlanClip.distance = 0.4
      })

      $('#btnShowF2').click(function () {
        terrainPlanClip.show = false
        tilesetPlanClip.distance = 3.5
      })
      $('#btnShowF3').click(function () {
        terrainPlanClip.show = false
        tilesetPlanClip.distance = 8.4
      })

      $('#btnShowF4').click(function () {
        terrainPlanClip.show = false
        tilesetPlanClip.distance = 12.4
      })

      $('#btnShowF5').click(function () {
        terrainPlanClip.show = false
        tilesetPlanClip.distance = 16.4
      })

      //键盘漫游
      map.keyboardRoam.setOptions({
        moveStep: 0.1, //平移步长 (米)。
        dirStep: 50, //相机原地旋转步长，值越大步长越小。
        rotateStep: 0.3, //相机围绕目标点旋转速率，0.3-2.0
        minPitch: 0.1, //最小仰角  0-1
        maxPitch: 0.95, //最大仰角  0-1
      })
      map.keyboardRoam.enabled = true //开启键盘漫游
    }

    function centerAtDX1() {
      map.setCameraView({
        y: 31.84371,
        x: 117.251041,
        z: 38.51,
        heading: 56.1,
        pitch: -8.1,
        roll: 0.1,
      })
    }

    function centerAtDX2() {
      map.setCameraView({
        y: 31.84381,
        x: 117.250991,
        z: 38.41,
        heading: 305.9,
        pitch: -12.3,
        roll: 359.9,
      })
    }

    function centerAtDX3() {
      map.setCameraView({
        y: 31.843787,
        x: 117.251172,
        z: 41.78,
        heading: 17.2,
        pitch: -9.3,
        roll: 0.1,
      })
    }
  </script>
</body>

</html>
